// 导入 vue-create-api
import CreateAPI from 'vue-create-api'
// 需导入vue
import Vue from 'vue'
// 导入组件
import Toast from '../components/common/Toast.vue'
import Popup from '../components/common/Popup.vue'
import GroupDialog from '../components/common/ShelfGroupDialog.vue'
// 调用 createAPI 生成对应 API，并挂载到 Vue.prototype
Vue.use(CreateAPI)
// 这里createAPI插件会将我们 扩展出在vue实例 叫做 createToast 方法
Vue.createAPI(Toast, true)
Vue.createAPI(Popup, true)
Vue.createAPI(GroupDialog, true)
Vue.mixin({
  methods: {
    dialog(showNewGroup, groupName) {
      return this.$createGroupDialog({ $props: showNewGroup, groupName })
    },
    toast(setting) {
      return this.$createToast({ $props: setting })
    },
    popup(title, btn) {
      return this.$createPopup({ $props: title, btn })
    },
    simpleToast(text) {
      this.toast({
        text: text
      }).show()
    }
  }
})
